package com.example.springmvc_adv.controller;

import com.example.springmvc_adv.exception.MyException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestController {

    private static final Map<String, Object> map = new HashMap<>();

    @RequestMapping("/1")
    public Object t1(){
        return map;
    }

    @RequestMapping("/2")
    public Object t2(String username) throws InterruptedException {

        if("abc".equals(username))
            throw new MyException("用户名或者密码错误");
//        Object o = null;
//        o.wait();
//
         return map;
    }

    @RequestMapping("/3")
    public Object t3()  {
        Map<String, Object> map = new HashMap<>();
        map.put("age",500);
        map.put("username","猴哥");
        return map;
    }
}
